package fr.univ.surveyonline.dispatcher;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import fr.univ.surveyonline.datastore.PMF;
import fr.univ.surveyonline.model.User;

public class ConnectUserServlet extends HttpServlet
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		long userId = Long.valueOf(req.getParameter("id"));
		User u = (User) PMF.getElementById(User.class, userId);
		
		if (u == null) {
			throw new IllegalStateException("pas Normal");
		}
		req.getSession().setAttribute("user", u);
		resp.sendRedirect("/debug.jsp");
	}

}
